package Framework
{
	import flash.display.Sprite;
	import flash.events.Event;
	
	/**
	 * ...
	 * @author Menno
	 */
	public class BaseGame extends Sprite
	{
		private var _currentLevel:String;
		private var _levelReader:LevelReader;
		protected var eventHandeler:BaseEventHandler;
		
		//Managers
		protected var entityManager:EntityManager;
		protected var guiManager:GuiManager;
		protected var entityRegister:EntityRegister;
		protected var guiRegister:GuiRegister;
		
		public function BaseGame() 
		{
			levelReader = new LevelReader();
			entityManager = new EntityManager();
			guiManager = new GuiManager(this);
			entityRegister = new EntityRegister(entityManager);
			guiRegister = new GuiRegister(guiManager);
			
			Main.main.addChild(this);
		}
		
		public function initGame():void
		{
			
		}
		
		protected function update(e:Event):void
		{
			entityManager.update();
		}
		
		protected function initLevel():void
		{
			
		}
		
		protected function drawLevel():void
		{
			guiManager.drawAll();
		}
		
		protected function startLevel():void
		{
			addEventListener(Event.ENTER_FRAME, update);
		}
		
		protected function stopLevel():void
		{
			removeEventListener(Event.ENTER_FRAME, update);
		}
		
		protected function get currentLevel():String
		{
			return _currentLevel;
		}
		
		protected function set currentLevel(value:String):void
		{
			_currentLevel = value;
		}
		
		protected function get levelReader():LevelReader
		{
			return _levelReader;
		}
		
		/**
		 * Probably not used.
		 */
		protected function set levelReader(value:LevelReader):void
		{
			_levelReader = value;
		}
	}
	
}